package com.zzw.hj27;

import java.util.*;

/**
 * @Project: hw_java
 * @Description: 查找兄弟单词
 * @Author: zzw
 */

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); //单词个数
        String[] strArr = new String[n];
        for (int i = 0; i < n; i++) {
            strArr[i] = in.next();
        }
        String strX = in.next();
        int k = in.nextInt();

        int broCount = 0;
        List<String> resultList = new ArrayList<>();
        for (int i = 0; i < strArr.length; i++) {
            if (isBroWord(strArr[i], strX)) {//判断是否为兄弟单词
                resultList.add(strArr[i]);
                broCount++;
            }
        }

        //对结果列表按字典排序
        Collections.sort(resultList);

        //兄弟单词个数
        System.out.println(broCount);
        //第k个兄弟单词
        if (k > broCount) {//错误处理，处理越界问题
            System.out.println();
        } else {
            System.out.println(resultList.get(k - 1));
        }
    }

    public static boolean isBroWord(String str, String strX) {
        if (str.length() != strX.length() || str.equals(strX)) {
            return false;
        }
        char[] charStr = str.toCharArray();
        Arrays.sort(charStr);
        char[] charStrX = strX.toCharArray();
        Arrays.sort(charStrX);
        for (int i = 0; i < charStr.length; i++) {
            if (charStr[i] != charStrX[i]) {
                return false;
            }
        }
        return true;
    }
}